<?php

require_once APPPATH . 'dao/configurationManager.php';

class RegionBoundingBox extends CI_Controller {

    /**
     * 
     * @param type $srs recibe por get el srs para consultar la lista
     */
    public function index($srs) {
        if ($this->session->userdata('logged_in')) {
            $data = array();
            $data['srs'] = array(
                'name' => 'srs',
                'id' => 'srs',
                'value' => urldecode($srs),
                'maxlength' => 40,
                'size' => 50,
                'type' => 'hidden'
            );
             $data['region'] = array(
                'name' => 'region',
                'id' => 'region',
                'value' => '',
                'maxlength' => 100,
                'size' => 120
            );
            $this->load->view('pages/selectRegionBoundingBox.php', $data);
         
        } else {
            redirect('login');
        }
    }

    public function getBoundingBox($srs,$regionFilter = '') {
        $this->load->model('region', '', TRUE);
       
        $srs = urldecode($srs);
        $regions = $this->region->getRegionBoundingBoxByName($regionFilter, $srs);

        echo json_encode($regions);
    }

}